/*
 * Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
 * 
 * This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
 * printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
 * without the written permission of iTAC Software AG.
 */
package org.template.portal;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

// TODO
/**
 * @author rafal.kojta
 */
@Entity
@Table(name = "year_group")
public class YearGroup {

  @Id
  @GeneratedValue(strategy = IDENTITY)
  @Column(name = "YEAR_GROUP_ID", unique = true, nullable = false)
  private long yearGroupId;

  @OneToOne(fetch = FetchType.LAZY, mappedBy = "yearGroup", cascade = CascadeType.ALL)
  private GroupCalendar groupCalendar;

  @OneToOne(fetch = FetchType.LAZY, mappedBy = "yearGroup", cascade = CascadeType.ALL)
  private RootDirectory rootDirectory;// root directory

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "COURSE_ID")
  private Course course;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "STUDENT_ID")
  private Student student;// founder

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "yearGroup")
  private Set<Post> posts;

  // @ManyToMany(fetch = FetchType.LAZY, mappedBy = "groups")
  // private Set<Student> students;
  @OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.yearGroup")
  private Set<StudentGroup> studentGroups = new HashSet<StudentGroup>(0);

  @Column(name = "NAME")
  private String name;

  @Column(name = "DESCRIPTION")
  private String description;

  @Column(name = "IRC_ADDRESS")
  private String ircAddress;

  public YearGroup() {

  }

  public long getYearGroupId() {
    return yearGroupId;
  }

  public void setYearGroupId(long yearGroupId) {
    this.yearGroupId = yearGroupId;
  }

  public Course getCourse() {
    return course;
  }

  public void setCourse(Course course) {
    this.course = course;
  }

  public Student getStudent() {
    return student;
  }

  public void setStudent(Student student) {
    this.student = student;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getIrcAddress() {
    return ircAddress;
  }

  public void setIrcAddress(String ircAddress) {
    this.ircAddress = ircAddress;
  }

  public GroupCalendar getGroupCalendar() {
    return groupCalendar;
  }

  public void setGroupCalendar(GroupCalendar groupCalendar) {
    this.groupCalendar = groupCalendar;
  }

  public Set<Post> getPosts() {
    return posts;
  }

  public void setPosts(Set<Post> posts) {
    this.posts = posts;
  }

  public RootDirectory getRootDirectory() {
    return rootDirectory;
  }

  public void setRootDirectory(RootDirectory rootDirectory) {
    this.rootDirectory = rootDirectory;
  }

  public Set<StudentGroup> getStudentGroups() {
    return studentGroups;
  }

  public void setStudentGroups(Set<StudentGroup> studentGroups) {
    this.studentGroups = studentGroups;
  }

}
